package org.zhq.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.zhq.ServerResult;

@RestControllerAdvice
public class CustomExceptionHandler {

    //上传文件超过500KB 捕获异常
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public ServerResult handlerMaxUploadFile(MaxUploadSizeExceededException ex){
        return ServerResult.errorMsg("文件上传大小不能超过500K,请压缩图片或者降低分辨率");
    }
}
